[tooltip] Improve support for disabled button triggers#48622
Conversation
Signed-off-by: Mayank <9084735+mayank99@users.noreply.github.com>
Tooltip warning about disabled buttons
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
Signed-off-by: Mayank <9084735+mayank99@users.noreply.github.com>
| if (childNode?.disabled) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
This needed to be removed as well in addition to the warning
There was a problem hiding this comment.
Thank you! I also found this when testing #48623 (comment)
| // However, if the trigger became disabled while the tooltip was already open, | ||
| // stray mouseover events must not cancel the pending close. |
There was a problem hiding this comment.
I added the openedByDisabledTriggerRef in order to not affect the existing "tooltip trigger becomes disabled while tooltip is open" case
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| await user.unhover(button); | ||
| await user.hover(screen.getByRole('tooltip')); | ||
| await act(async () => { | ||
| await new Promise((resolve) => { | ||
| setTimeout(resolve, 600); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
shouldn't the flow be: unhover button, wait for some time not enough for the tooltip to disappear, hover the tooltip, then check?
There was a problem hiding this comment.
@mj12albert Since you wrote this test, would you be able to help with this?
Edit: Addressed in 1ef6079.
Main changes
This PR removes the warning that is triggered when
Tooltipis used on a<button disabled>element. This warning is unnecessary in 2026 and encourages bad patterns. See #33182 (comment) for longer explanation.Additionally,
5a10feeremoves the disabled guard from #48606 and replaces it with better handling of disabled button triggers.Documentation
The "Disabled elements" section of the Tooltip docs has been reworked to remove the wrapper
<span>recommendation.pointer-events: noneneeds to be undone from Buttons (see related section in Button docs). I believe this should be addressed withinButtonBasein a separate PR.focusableWhenDisabledprop (when available).